﻿@model PH.Model.Accounts.UserModel
@{
    Layout = "../Shared/_Layout.cshtml";
}

<div id="header">
    <div>
        <h2>重置密码</h2>
    </div>
</div>

<div class="container-fluid">
    <div class="wheelContainer">
        <form method="post" action="#">
            <div class="row-fluid">
                <div class="span12">
                    <div class="row-fluid">
                        <label for="txtPassword" class="span12">
                            用户名：
                            <span class="icon16 icomoon-icon-user-3 right gray marginR10"></span>
                        </label>
                        <input type="text" id="txtPassword" name="username" class="span12" tabindex="1" value="@Model.UserName" readonly="readonly" />
                    </div>
                    <div class="row-fluid">
                        <label for="txtNewPassword" class="span12">
                            新密码：
                            <span class="icon16 icomoon-icon-user-3 right gray marginR10"></span>
                        </label>
                        <input type="password" placeholder="新的密码必须至少8位字符（字母+数字组成）" id="txtNewPassword" name="newPassword" class="span12" tabindex="2" />
                    </div>

                    <div class="row-fluid">
                        <label for="txtPassword" class="span12">
                            重复密码：
                                <span class="icon16 icomoon-icon-locked right gray marginR10"></span>

                        </label>
                        <input type="password" placeholder="请重复输入密码" id="txtRepeat" name="repeat" class="span12" tabindex="3" />
                    </div>

                    <div class="row-fluid" id="msg" style="display: none">
                        <div class="alert alert-error">
                            <b>错误：</b>
                            <span>用户名或密码错误</span>
                        </div>
                    </div>
                    <div class="row-fluid">
                        <div class="form-action">
                            <button id="loginBtn" class="btn btn-info right" type="submit" tabindex="4">
                                <span class="icon16 icomoon-icon-enter white"></span>
                                提 交
                            </button>
                        </div>
                    </div>

                </div>
            </div>
        </form>
    </div>
</div>

<div id="OkPanel" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-body">
        <p><b>恭喜您，密码修改成功。</b><a href="/Accounts/User/Login">点击这里，用新密码重新登陆。</a> </p>
    </div>
</div>

<script>
    $(function () {
        $("#loginBtn").click(function () {
            $("#msg").toggle(false);

            var p = $("#txtNewPassword").val();
            var r = $("#txtRepeat").val();
            if (p == r) {
                Whale.Remote.Operation({
                    url: "/Accounts/User/ResetPassword",
                    parameters: {
                        guid: "@Model.Guid",
                        password: $("#txtNewPassword").val(),
                    },
                    success: function (response) {
                        //location.href = url;
                        $('#OkPanel').modal({})
                    },
                    error: function (msg) {
                        $("#msg div span").html(msg);
                        $("#msg").fadeIn();
                    }
                });
            } else {
                $("#msg div span").html("两次密码输入不一致。");
                $("#msg").fadeIn();
            }
            return false;
        });
    });
</script>
